package org.benjamin.lending.hander;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import org.springframework.web.util.WebUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by xywen on 2017/6/9.
 */
public class TokenCheckInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String token = (String) WebUtils.getSessionAttribute(request,"TOKEN");
        String inputToken = request.getParameter("token");
        return token.equalsIgnoreCase(inputToken);
    }
}
